<?php
/*
 * 投资案例
 */
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class UserProject extends Model
{
    //
    protected $table = 'user_project';

    protected $fillable = array('uid', 'name','datetime','username','lines');

    protected function getDateFormat()
    {
        return 'U';
    }
	
    /**
     * userproject 有改动的时候刷新缓存
     * @param unknown_type $user
     */
    static function refreshCache($user){
    	$userProjects=array();
    	if(count($user->userProjects)){
    		foreach($user->userProjects as $k=>$v){
					$userProjects[$k]['id']=$v->id;
					$userProjects[$k]['name']=$v->name;
    		}
    	}
    	Cache::forever('user_projects_'.$user->uid, $userProjects,1);
    }
}
